import Taro from '@tarojs/taro'
import { prefix } from '../utils'

export function add(payload, callback) {
    return () => {
        const userInfo = Taro.getStorageSync('userInfo')

        Taro.request({
            url: `${prefix}/api/v1/feedbacks`,
            data: {...userInfo, ...payload, type: 0},
            method: 'POST',
            header: { 'content-type': 'application/json', 'Authorization' : `Bearer ${userInfo.token}` }
        })
        .then(results => {
            const { data = {} } = results || {}
            if(callback) callback(data)
        })
    }
}